-if(action == 'update')
	script(type='text/javascript')
		$("body").ready(function() {
			$("#editSave").hide();
			setAction = function(name) {
				$("#edit" + name + "Field").hide();
				$("#edit" + name).click(function() {
					$("#edit" + name + "Value").hide();
					$("#edit" + name + "Field").fadeIn('slow');
					$("#edit" + name + "Field").focus();
					$("#editSave").fadeIn('slow');
				});
			};
		});

-if(action == 'add') 
	script(type='text/javascript')
		$("body").ready(function() {
			setAction = function(name) {
				$("#edit" + name + "Value").hide();
			};
		});

script(type='text/javascript')
	$("body").ready(function() {
		setAction('Name');
		setAction('ID');
		setAction('Direction');
		setAction('Type');
		setAction('Description');
	});

form(
	method='post',
	action='/ports',
	enctype='application/x-www-form-urlencoded')
	table
		tr
			td.neutral(colspan='2')
				h3 Port Configuration
				input#editSave(type='submit',value='Save')
				input(type='hidden',name='action',value= action)
				input(type='hidden',name='_id',value= port._id)
		tr
			td.neutral.editLabel Name
			td.neutral#editName
				#editNameValue= port.name
				input#editNameField(type='text',name='name',value= port.name)
		tr
			td.neutral.editLabel Device
			td.neutral(onclick='window.location=\'/devices/'+ port.device._id +'\'')= port.device.name
				input(type='hidden',name='device',value= port.device._id)
		tr
			td.neutral.editLabel ID
			td.neutral#editID
				#editIDValue= port.id
				input#editIDField(type='text',name='id',value= port.id)
		tr
			td.neutral.editLabel Value
			td.neutral= port.value
		tr
			td.neutral.editLabel Type
			td.neutral#editType
				#editTypeValue= port.type
				select#editTypeField(name='type')
					option(value='String') String
					option(value='Number') Number
					option(value='Boolean') Boolean
		tr
			td.neutral.editLabel Direction
			td.neutral#editDirection
				#editDirectionValue= port.direction
				select#editDirectionField(name='direction')
					option(value='Input') Input
					option(value='Output') Output
					option(value='Bidirectional') Bidirectional
		tr
			td.neutral.editLabel Description
			td.neutral#editDescription
				#editDescriptionValue= port.description
				input#editDescriptionField(type='text',name='description',value=port.description)
